<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/5/25
  Time: 19:46
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<html>
<head>
    <title>showAll</title>
</head>
<body>
<table class="show" style="border:1px blue solid;" cellpadding="0" cellspacing="0" border="1">
    <tr><th colspan="7">信息展示</th></tr>
    <tr>
        <th>mid</th>
        <th>mname</th>
        <th>mgender</th>
        <th>age</th>
        <th>maddress</th>
        <th>memail</th>
        <th>操作</th>
    </tr>
    <c:forEach var="membersInfo" items="${membersInfoList}">
        <tr id="${membersInfo.mid}">
            <td><a href="../mem/findOne?id=${membersInfo.mid}">${membersInfo.mid}</a></td>
            <td>${membersInfo.mname}</td>
            <td><c:if test="${membersInfo.mgender == 1}">男</c:if>
                <c:if test="${membersInfo.mgender == 0}">女</c:if></td>
            <td>${membersInfo.age}</td>
            <td>${membersInfo.maddress}</td>
            <td>${membersInfo.memail}</td>
            <td><input type="button" onclick="deleteId(${membersInfo.mid})" value="删除" ></input></td>
            <!-- href="../mem/delete?id=${membersInfo.mid} -->
        </tr>
    </c:forEach>
</table>
</body>
</html>

<script src="${pageContext.request.contextPath}/statics/js/jquery-3.5.1.js"></script>
<script>
    function deleteId(id, obj){
        $.post("../mem/delete", {"id": id}, function (data){
            if(data == "1" ){
                alert("删除成功");
                var o = document.getElementById(id);
                o.parentNode.removeChild(o);

            }else{
                alert("删除失败");
            }
        }, "json");
        <%-- findAgain(); --%>
    }

    function findAgain(){
        window.location.href="redirect:../mem/find";
        alert("执行window.location.href了");
    }

</script>

<!--
var ht = "";
ht += "<table class='show' style='border:1px blue solid;' cellpadding='0' cellspacing='0' border='1'>";
ht += "<tr><th colspan='7'>信息展示</th></tr>";
ht += " <tr> <th>mid</th> <th>mname</th> <th>mgender</th> <th>age</th> <th>maddress</th> <th>memail</th> <th>操作</th> </tr>";
for(var i = 0; i <data.length(); i++) {
ht += "<tr><td><a href='../mem/findOne?id=${data[i].mid}''>${data[i].mid}</a></td>";
ht += " <td>${data[i].mname}</td>";
ht += "<td><c:if test='${data[i].mgender == 1}'>男</c:if><c:if test='${data[i].mgender == 0}'>女</c:if></td>";
ht += "<td>${data[i].age}</td> <td>${data[i].maddress}</td> <td>${data[i].memail}</td>";
ht += "<td><input type='button' onclick='deleteId(${data[i].mid})' value='删除' ></input></td>";
}
$(".show").html(ht);
-->